package com.example.swimmingpool.controller.course;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.swimmingpool.qo.course.CourseQo;
import com.example.swimmingpool.response.CommonResponse;
import com.example.swimmingpool.service.course.CourseService;
import com.example.swimmingpool.vo.course.CourseQueryVo;
import com.example.swimmingpool.vo.course.CourseVo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/course")
public class CourseController {
    @Resource
    private CourseService courseService;

    @PostMapping("/add")
    public CommonResponse<Boolean> add(@RequestBody CourseVo vo) {
        var res = courseService.add(vo);
        return CommonResponse.success(res);
    }

    @PostMapping("/list")
    public CommonResponse<IPage<CourseQueryVo>> list(@RequestBody CourseQo qo) {
        var pages = courseService.list(qo);
        return CommonResponse.success(pages);

    }

    @PostMapping("/delete")
    public CommonResponse<Boolean> delete(@RequestBody CourseVo vo) {
        var res = courseService.delete(vo);
        return CommonResponse.success(res);
    }

    @PostMapping("/update")
    public CommonResponse<Boolean> update(@RequestBody CourseVo vo) {
        var res = courseService.update(vo);
        return CommonResponse.success(res);
    }


}
